﻿//剪刀=1 石头=2 布=3
#include<iostream>
#include<ctime>
#include<string>
using namespace std;
struct m { int a; int b; };//结构里的玩家 a,b;
int main() {
	cout << "***********************" << endl;
	cout<<"版本提示：稳定版V2.0.1" << endl;
	cout << "***********************\n\n" << endl;
	m f;
	int u = 0;
	srand((unsigned int)time(NULL));//随机种子
	double c = 0, z = 0, y = 0, at = 0;
	cout << "模拟玩家输出:\n";
	for (int d = 1; d <= 1000; d++) {
		f.a = rand() % 3 + 1;
		f.b = rand() % 3 + 1;
		at++;
		//A玩家
		if (f.a == 1 && f.b == 3) {//A出1	
			cout << "A玩家获胜" << ",A出了剪刀 B出了布" << endl;
			cout << "=====================================" << endl;
			c++;
		}	
		if (f.a == 2 && f.b == 1) {//特殊情况 A出2
			cout << "A玩家获胜" << ",A出了石头 B出了剪刀" << endl;
			cout << "=====================================" << endl;
			c++;
		}
		if (f.a == 3 && f.b ==2) {
			cout << "A玩家获胜" << ",A出了布 B出了石头" << endl;
			cout << "=====================================" << endl;
			c++;
			}
			//B玩家-------------------------------------------------
		if (f.b == 1 && f.a == 3) {//A出1
			cout << "B玩家获胜" << ",B出了剪刀 A出了布" << endl;
			cout << "=====================================" << endl;
			z++;
		}
			if (f.b == 2 && f.a == 1) {//特殊情况 A出2
			cout << "B玩家获胜" << ",B出了石头 A出了剪刀" << endl;
			cout << "=====================================" << endl;
			z++;
		}
			if (f.b == 3 && f.a == 2) {
			cout << "B玩家获胜" << ",B出了布 A出了石头" << endl;
			cout << "=====================================" << endl;
			z++;
		}
			//平局
		if (f.a == f.b) {
			y++;
		}
	}
	cout << "\n\n\n**************************************\n";
	cout << "*------------------------------------*\n";
	cout << "*==============统计信息==============*\n";
	cout << "*=========A玩家共计获胜：" << c << "次=======*" << endl;
	cout << "*=========B玩家共计获胜：" << z << "次=======*" << endl;
	cout << "*=======本次对弈共计平局：" << y << "次======*" << endl;
	cout << "*------------------------------------*\n";
	cout << "**************************************\n";
	//胜率计算
	cout << "经过" << at << "次对弈得出:";
	cout << "A胜率:" << (c/at);
	cout << " B胜率:" << (z/ at) << endl;
	cout << "作者:子立大聪明  \n创作时间:2021年7月15日 重置时间“同年8月27日”\n联系作者: B站UID:399313598.\n\n\n" << endl;
	int temp=0;
	cout << "查看修复日志 请输入0\n";
	cin>> temp;
	if (temp == 0) {
		cout << "此版本为发版第二版 从根源修复了逻辑上的错误" << endl;
	}
	cin.get();//停留 显示结果
	return 0;
}